
Date.prototype.Format = function (fmt) {
  let o = {
    "M+": this.getMonth() + 1, //月份
    "d+": this.getDate(), //日
    "h+": this.getHours(), //小时
    "m+": this.getMinutes(), //分
    "s+": this.getSeconds() //秒
  };
  if (/(y+)/.test(fmt)){ //根据y的长度来截取年
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (let k in o){
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  }
  return fmt;
}
const DATEUtils = {}
DATEUtils.format = (timeStr,format)=>{
  let srt = timeStr.replaceAll("-","?").replaceAll("T","?").replaceAll(":","?")
  let arr = srt.split("?")
  let date = `${arr[0].trim()}/${arr[1].trim()}/${arr[2].trim()} ${arr[3].trim()}:${arr[4].trim()}:${arr[5].trim()}`
  let dateBean =  new Date(date)
  if (format!==null&&format!==undefined&&format.trim()!==""){
    dateBean = dateBean.Format(format)
  }else{
    dateBean = dateBean.Format("yyyy-MM-dd hh:mm:ss")
  }
  return dateBean
}
DATEUtils.name = 'DATEUtils'
export default DATEUtils
